import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1

Button {
    width: (parent.width / parent.columns) - parent.spacing
    height: (parent.height / parent.rows) - parent.spacing
    visible: false

    property string textColor;
    property string color
    property string pressedColor

    property var data
    property var visibleTime
    property var pressTime

    signal buttonSelected(var button, var data)
    onClicked: buttonSelected(this, data);

    style: ButtonStyle {
        label: Text {
            antialiasing: true
            renderType: Text.NativeRendering
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            text: control.text
            font.bold: true
            font.pixelSize: 20
            color: {
                if (control.enabled)
                    return control.pressed ? "white" : textColor
                else
                    return "#C0C0C0";
            }

            wrapMode: Text.Wrap
            elide: Text.ElideRight
            maximumLineCount: 5
        }
        background: Rectangle {
            antialiasing: true
            implicitWidth: 100
            implicitHeight: 25
            border.width: control.activeFocus ? 2 : 1
            border.color: control.pressed ? control.pressedColor : "#888"
            radius: 8
            color: {
                if (control.enabled)
                    return control.pressed ? control.pressedColor : control.color
                else
                    return "#EBECE4";
            }

        }
    }
}
